<?php
require 'class.compliance.php';
if (isset($_POST['amh_ID'])) {
    if (substr($SESSST, 1, 1) != 'A') {
        $_POST['amh_Comentario'] = req_form($_POST['amh_Comentario']);
        $GLOBALS['MYT']->db_query("UPDATE hd_amlalertas
					SET amh_Comentario = '{$_POST['amh_Comentario']}',
					amh_Status = {$_POST['amh_Status']},
					amh_UsrComenta = {$_SESSION[$SESSID]},
					amh_FechaComenta = '{$sysTime}'
					WHERE amh_ID = {$_POST['amh_ID']}");
        $AMLDOps = $GLOBALS['MYT']->db_array("SELECT amd_Desc FROM hd_amldetalle
					WHERE amd_Alerta = {$_POST['amh_ID']}");
        $POOL = $_POST['amh_Operacion'];
        if ($AMLDOps[1]['amd_Desc'] != '') {
            $POOL = $_POST['amh_Operacion'] . ',' . str_replace(';', ',', $AMLDOps[1]['amd_Desc']);
        }
        if (isset($_POST['ConfBlock']) && $_POST['amh_Status'] == 1) {
            if ($GLOBALS['MYT']->db_query("UPDATE facturas
					SET FraStatus = 2
					WHERE FraID IN ({$POOL})
						AND FraStatus IN (12,13,14)") == true) {
                require_once($GLOBALS['BIB'] . 'Pr_db/pr_historics');
                system_hs($sysTime, 'AML_CLOSE', $_POST['amh_ID']);
            }
        }
    } else {
        $EditAML = new Compliance();
        if (!isset($_POST['ConfBlock'])) {
            $_POST['ConfBlock'] = 1;
        }
        if($_POST['amh_Status']<0) {$_POST['ConfBlock'] = 0;}

        $UnblockAml = $EditAML->AMLUnblock($_POST['amh_ID'], req_form($_POST['amh_Comentario']),
                        req_form($_POST['amh_Reply']), $_POST['amh_Status'], $_POST['amh_Operacion'], $_POST['ConfBlock']);
    }
echo '<div class="Confirm">Guardado.</div>';
} else {
echo '<div class="Error">Erro ao salvar alerta.</div>';
}